﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Web;

namespace NLBS.Resources
{
   public class ResourceManager
    {
       public static string GetString(string key)
       {
          return Language.Instance().GetResource(key);
       }

       /// <summary>
       /// 注册语言文件，默认为当前语言
       /// </summary>
       /// <param name="filePath">文件路径</param>
       public static void RegisterLanguageFile(string filePath)
       {
           RegisterLanguageFile(BlogInfo.Instance().Language, filePath);
       }

       /// <summary>
       /// 注册语言文件
       /// </summary>
       /// <param name="language">语言</param>
       /// <param name="filePath">文件路径</param>
       public static void RegisterLanguageFile(string language,string filePath)
       {
           string file=HttpContext.Current.Server.MapPath(filePath);
           string dir=string.Format(HttpContext.Current.Server.MapPath("/App_Data/Language/{0}/"),language);
           File.Copy(file, dir + Path.GetFileName(file),true);

           //clear cache
           ContentCache.Instantiate().Remove("nlbslanguage");
       }
    }
}
